package zut.edu.cs.network.io.print;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;

public class PrintStreamDemo {

	public static void main(String[] args) {
		PrintStream ps;
		try {
			ps = new PrintStream("print.txt");
			ps.println("this is a test");
//			用字节数组的方式写入到文件 write(byte[])
			ps.write("sweet".getBytes());
//			用整型数传入到文件中，此时的65指的是A write(int)
			ps.write(65);
//			0x63是一个十六进制数，代表c
			ps.write(0x63);
			ps.println();
			ps.println("the book is 666");
//		printf的用法，借助正则表达式 格式化输出
			ps.printf("%s %s is %d", "the","book",66);
			ps.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

	}

}
